/*
 * BrowsingHistoryListItem.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.yidiandao.business.R;
import com.yidiandao.business.data.realm.BrowingHistoryBean;
import com.yidiandao.business.ui.goodsdetail.GoodsDetailActivity;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.BrowsingHistoryHolder;
import com.yidiandao.business.utils.ImageLoader;
import com.yidiandao.business.utils.UmengUtils;

/** 浏览记录 */
public class BrowsingHistoryListItem
        extends DisplayListItem<BrowsingHistoryHolder, BrowingHistoryBean> {

    public BrowsingHistoryListItem(BrowingHistoryBean s) {
        super(s);
    }

    @Override
    public void onShow(final Context context, BrowsingHistoryHolder holder) {
        final String goods_id = data.getGoods_id();
        String goodsImgUrl = data.getGoodsImgUrl();
        final String goodsName = data.getGoodsName();
        String price = data.getPrice();
        ImageLoader.loadImage(context, holder.mIvItemPic, goodsImgUrl);
        holder.mTvItemBrowsingHistoryName.setText(goodsName);
        holder.mTvItemBrowsingHistoryPrice.setText(price);

        final Activity activity = (Activity) context;
        holder.mRlItemBrowsingHistory.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        UmengUtils.onEvent(context, R.string.umeng_browsing_detail);
                        GoodsDetailActivity.actionStart(activity, goods_id);
                    }
                });
    }

    @Override
    public String getDisplayItemTag() {
        return BrowsingHistoryListItem.class.getSimpleName();
    }

    @Override
    public Class<BrowsingHistoryHolder> getViewHolderClazz() {
        return BrowsingHistoryHolder.class;
    }
}
